<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Add a job server to the client</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gearmanclient.addoptions.html">GearmanClient::addOptions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="gearmanclient.addservers.html">GearmanClient::addServers</a></div>
 <div class="up"><a href="class.gearmanclient.html">GearmanClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="gearmanclient.addserver" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">GearmanClient::addServer</h1>
  <p class="verinfo">(PECL gearman &gt;= 0.5.0)</p><p class="refpurpose"><span class="refname">GearmanClient::addServer</span> &mdash; <span class="dc-title">Add a job server to the client</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-gearmanclient.addserver-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>GearmanClient::addServer</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$host</code><span class="initializer"> = 127.0.0.1</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$port</code><span class="initializer"> = 4730</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Adds a job server to a list of servers that can be used to run a task.  No socket
   I/O happens here; the server is simply added to the list.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-gearmanclient.addserver-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">host</code></em></dt>

     <dd>

      <p class="para">
       任务服务器主机名。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">port</code></em></dt>

     <dd>

      <p class="para">
       任务服务器端口号。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-gearmanclient.addserver-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-gearmanclient.addserver-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4220">
    <p><strong>Example #1 Adding two job servers</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">#&nbsp;Create&nbsp;our&nbsp;client&nbsp;object.<br /></span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">GearmanClient</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">#&nbsp;Add&nbsp;two&nbsp;job&nbsp;servers,&nbsp;the&nbsp;first&nbsp;on&nbsp;the&nbsp;default&nbsp;4730&nbsp;port<br /></span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"10.0.0.1"</span><span style="color: #007700">);&nbsp;<br /></span><span style="color: #0000BB">$gmclient</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addServer</span><span style="color: #007700">(</span><span style="color: #DD0000">"10.0.0.2"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">7003</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-gearmanclient.addserver-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="gearmanclient.addservers.html" class="methodname" rel="rdfs-seeAlso">GearmanClient::addServers()</a> - Add a list of job servers to the client</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="gearmanclient.addoptions.html">GearmanClient::addOptions</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="gearmanclient.addservers.html">GearmanClient::addServers</a></div>
 <div class="up"><a href="class.gearmanclient.html">GearmanClient</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
